{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "********** Start recording for 5 seconds! **********\n",
      "..........1s\n",
      "\n",
      "..........2s\n",
      "\n",
      "..........3s\n",
      "\n",
      "..........4s\n",
      "\n",
      "..........5s\n",
      "\n",
      "********** Stop recording! **********\n",
      "{\"refresh_token\":\"25.3d1e4992da70379a213ab1701c2a70c5.315360000.2060920960.282335-118650883\",\"expires_in\":2592000,\"session_key\":\"9mzdXUbNL\\/7va+CRHkbapMWqU4Gey4MsBaHALEKpDtVW+j6zn077fKFrtdiYZtuL+aDyij4Hn+3mdmpa+cr+WRJxlAFE4x4=\",\"access_token\":\"24.f2eb293f5a8146f810167dfb9ffaec0b.2592000.1748152960.282335-118650883\",\"scope\":\"public audio_voice_assistant_get audio_tts_post brain_all_scope brain_enhanced_asr brain_speech_realtime brain_asr_async wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\\u6743\\u9650 vis-classify_flower lpq_\\u5f00\\u653e cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_\\u5f00\\u653eScope vis-ocr_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406 idl-video_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406 smartapp_component smartapp_search_plugin avatar_video_test b2b_tp_openapi b2b_tp_openapi_online smartapp_gov_aladin_to_xcx\",\"session_secret\":\"d6ef69c32d7d231980390878ea776509\"}\n",
      "\n",
      "{'refresh_token': '25.3d1e4992da70379a213ab1701c2a70c5.315360000.2060920960.282335-118650883', 'expires_in': 2592000, 'session_key': '9mzdXUbNL/7va+CRHkbapMWqU4Gey4MsBaHALEKpDtVW+j6zn077fKFrtdiYZtuL+aDyij4Hn+3mdmpa+cr+WRJxlAFE4x4=', 'access_token': '24.f2eb293f5a8146f810167dfb9ffaec0b.2592000.1748152960.282335-118650883', 'scope': 'public audio_voice_assistant_get audio_tts_post brain_all_scope brain_enhanced_asr brain_speech_realtime brain_asr_async wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base smartapp_mapp_dev_manage iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理 smartapp_component smartapp_search_plugin avatar_video_test b2b_tp_openapi b2b_tp_openapi_online smartapp_gov_aladin_to_xcx', 'session_secret': 'd6ef69c32d7d231980390878ea776509'}\n",
      "SUCCESS WITH TOKEN: 24.f2eb293f5a8146f810167dfb9ffaec0b.2592000.1748152960.282335-118650883 ; EXPIRES IN SECONDS: 2592000\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.f2eb293f5a8146f810167dfb9ffaec0b.2592000.1748152960.282335-118650883&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/wav; rate=16000', 'Content-Length': 200044}\n",
      "Request time cost 1.239029\n",
      "龙v101224115啊！\n",
      "{\"corpus_no\":\"7497127237744187055\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"龙v101224115啊！\"],\"sn\":\"646456260291745560960\"}\n",
      "\n",
      "语音识别结果 = 龙v101224115啊！\n"
     ]
    }
   ],
   "source": [
    "\n",
    "#导入依赖包\n",
    "import asr_raw as ar#百度语音识别包\n",
    "from RecordPlay import recorder#录音包\n",
    "#录音5s,保存音频到test.wav文件\n",
    "r = recorder()\n",
    "r.recorder(\"test.wav\")\n",
    "#识别录音结果\n",
    "result_str = ar.Voice2Text(\"test.wav\")#识别语音\n",
    "#打印录音结果\n",
    "print(\"语音识别结果 = \" + result_str)#打印识别结果\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "fordetect",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.20"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
